﻿using System;
using System.ComponentModel.Composition;
using System.Waf.Applications;
using System.Windows.Input;
using WafApplication1.Applications.Views;
using System.Waf.Applications.Services;
using WafApplication1.Applications.Services;

namespace WafApplication1.Applications.ViewModels
{
    [Export]
    public class ShellViewModel : ViewModel<IShellView>
    {
        private readonly DelegateCommand exitCommand;
        private readonly DelegateCommand alertCommand;
        private readonly IMessageService message;
        private readonly IShellService shellService;    

        [ImportingConstructor]
        public ShellViewModel(IShellView view, IMessageService message, IShellService shellService)
            : base(view)
        {
            exitCommand = new DelegateCommand(Close);
            alertCommand = new DelegateCommand(MyAlert);
            this.message = message;
            this.shellService = shellService;
        }

        private void MyAlert()
        {
            // 用于测试
            message.ShowMessage("这是对话框!");
        }

        public string Title { get { return ApplicationInfo.ProductName; } }

        public ICommand ExitCommand { get { return exitCommand; } }
        public ICommand AlertCommand { get { return alertCommand; } }
        public IShellService ShellService { get { return shellService; } }

        public void Show()
        {
            ViewCore.Show();
        }

        private void Close()
        {
            ViewCore.Close();
        }
    }
}
